package com.vimae.android.toneranger;

import java.util.Date;
import java.util.Timer;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ToneRanger extends Activity {
	
    static final private int CLEAR_ID = Menu.FIRST;
    static final private int SAVE_ID = Menu.FIRST + 1;
    private EditText textBox;
    private Button runButton;
    private TextView status;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        textBox = (EditText)findViewById(R.id.textBox);
        runButton = (Button)findViewById(R.id.runButton);
        runButton.setOnClickListener(ExecuteScript);
        status = (TextView)findViewById(R.id.statusLabel);
        status.setVisibility(0);
    }
    
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);

        // We are going to create two menus. Note that we assign them
        // unique integer IDs, labels from our string resources, and
        // given them shortcuts.
        menu.add(0, SAVE_ID, 0, "Save this Script").setEnabled(false);
        menu.add(0, CLEAR_ID, 0, "Clear Script");
        
        return true;
    }
    
    OnClickListener ExecuteScript = new OnClickListener() {
        public void onClick(View v) {
        	Timer timer = new Timer(true);
        	Date d = new Date();
        	PlayScript p = new PlayScript(textBox.getText().toString());
        	timer.schedule(p, 0, 1 * 100);
        }
    };
   

}